package mk.company.fin.frame.report.internal;

import java.awt.Dimension;
import java.beans.PropertyVetoException;

import javax.swing.JComponent;
import javax.swing.JFrame;

import mk.company.fin.AppConstants;
import mk.company.fin.frame.internal.AbstractInternalFrame;
import mk.company.fin.service.MessageService;
import mk.company.fin.service.ModelService;

import org.springframework.context.ApplicationContext;

public class AnalyticCardReportFrame extends AbstractInternalFrame {

	private static final long serialVersionUID = 8930824031275692677L;
	
	/* SERVICES */
	
	private MessageService messageService;
	private ModelService modelService;

	
	//component which this frame will be drawn
	JComponent component;
	public AnalyticCardReportFrame(JComponent component) {
		this.component=component;
		
	}
	
	@Override
	public void initialize(ApplicationContext context) {
		setContext(context);
		injectServices();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(new Dimension(AppConstants.MainFrame.WIDTH, AppConstants.MainFrame.HEIGHT));
		// components
		initComponents();
	}

	/**
	 * Inject services.
	 */
	private void injectServices() {
		messageService = getContext().getBean(MessageService.class);
		modelService=getContext().getBean(ModelService.class);
	}
	
	public void initComponents() {
		// title
		setTitle(messageService.getMessage("comintent.conto.plan"));
		// Size
		this.setSize(AppConstants.MainFrame.WIDTH, AppConstants.MainFrame.HEIGHT);
		// Maximize
		try {
			this.setMaximum(true);
		} catch (PropertyVetoException e) {
		} catch (NullPointerException n) {
		}
		// Layout
		this.setLayout(null);
		
		//Set the layout of all the panels
		setLayout();
		
		this.setVisible(true);
		component.add(this);
	}
	
	private void setLayout(){
	
	}
	@Override
	public void draw() {
		injectServices();
		initComponents();
	}

}
